package com.eyealike.client.util;

import java.io.IOException;
import java.io.UnsupportedEncodingException;

import net.iharder._Base64;

public class Base64
{
	public static String base64Encode( final byte[] bytes )
	{
		return _Base64.encodeBytes( bytes );
	}

	public static String base64Encode( final String input )
	{
		try {
			return _Base64.encodeBytes( input.getBytes( "UTF-8" ) );
		} catch( final UnsupportedEncodingException e ) {
			throw new RuntimeException( e );
		}
	}

	public static byte[] base64DecodeBytes( final String input )
	{
		try {
			return _Base64.decode( input );
		} catch( final IOException ioe ) {
			throw new RuntimeException( ioe );
		}
	}

	public static String base64Decode( final String input )
	{
		try {
			return new String( _Base64.decode( input ) );
		} catch( final IOException ioe ) {
			throw new RuntimeException( ioe );
		}
	}
}
